package com.industrial.governance.controller;

import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.governance.domain.QueryParams;
import com.industrial.governance.service.IBigPingService;
import com.industrial.governance.service.IDataAcquisitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/bigping")
public class BigPingController {


    @Autowired
    private IBigPingService bigPingService;

    @Autowired
    private IDataAcquisitionService dataAcquisitionService;

    /**
     * 查询各地市的数据数量
     * @return
     */
    @GetMapping("/queryCityDataCj")
    public AjaxResult queryCityDataCj(QueryParams params){
        params.setProvince("370000");
        Map<String, Object> resultMap = dataAcquisitionService.queryCityDataCj(params);
        return AjaxResult.success(resultMap);
    }

    /**
     * 各部门数据采集维度统计
     * @return
     */
    @GetMapping("/queryDataCaiJi")
    public AjaxResult queryDataCaiJi(){
        List<Map<String, Object>> maps = bigPingService.queryDataCaiJi();
        return AjaxResult.success(maps);
    }

    @GetMapping("/queryCompanyCount")
    public AjaxResult queryCompanyCount(QueryParams params){
        Map<String,Object> result =  bigPingService.queryCompanyCount(params);
        return AjaxResult.success(result);
    }

    /**
     * 各地市数据质量问题数量
     * @return
     */
    @GetMapping("/queryCityDataQuality")
    public AjaxResult queryCityDataQuality(QueryParams params){

//        QueryParams params = new QueryParams();
//
//        LocalDate localDate = LocalDate.now();
//        params.setYears(String.valueOf(localDate.getYear() - 1));
        Map<String, List<String>> resultMap = bigPingService.queryCityDataQuality(params);
        return AjaxResult.success(resultMap);
    }
}
